import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'logic.dart';

class DeliverExpressPage extends StatefulWidget {
  const DeliverExpressPage({Key? key}) : super(key: key);

  @override
  State<DeliverExpressPage> createState() => _DeliverExpressPageState();
}

class _DeliverExpressPageState extends State<DeliverExpressPage> {
  final DeliverExpressLogic logic = Get.put(DeliverExpressLogic());

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: MGColors.whileColor,
      appBar: HLAppBar(
        navigationTitle: "设置快递公司",
        showBottomLine: true,
      ),
      body: HLScrollView(
        padding: EdgeInsets.only(left: 20, right: 20, bottom: 100),
        children: logic.expressLogic.expressList
            .map((e) => MGItems(
                  leadTitle: e.fullName,
                  trailingWidget: GetBuilder<DeliverExpressLogic>(
                      id: e.id.toString(),
                      builder: (controller) {
                        return controller.listID.contains(e.id)
                            ? Image.asset(
                                MGImage.image("public_pass"),
                                width: 20,
                              )
                            : Image.asset(
                                MGImage.image("public_no_pass"),
                                width: 20,
                              );
                      }),
                  action: () {
                    logic.selectAction(e.id);
                  },
                ))
            .toList(),
      ),
      bottomSheet: MGButton(
        title: "确认",
        padding: EdgeInsets.only(left: 30, right: 30, bottom: 30, top: 15),
        buttonAction: logic.sureAction,
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<DeliverExpressLogic>();
    super.dispose();
  }
}
